package com.heima.utils.threadLocal;

import com.heima.model.wemedia.pojos.WmUser;

public class WmThreadLocalUtil {
    private final static ThreadLocal<WmUser> wmUserThreadLocal=new ThreadLocal<>();
    public static void setUser(WmUser user)
    {
        wmUserThreadLocal.set(user);
    }
    public static WmUser getUser()
    {
        return wmUserThreadLocal.get();
    }
    public static void clear()
    {
        wmUserThreadLocal.remove();
    }
    public static Integer getUserId(){
        return wmUserThreadLocal.get().getId();
    }
    public static void setUserId(Integer userId)
    {
        WmUser wmUser = new WmUser();
        wmUser.setId(userId);
        setUser(wmUser);
    }
}
